package homework1;

class Player {
    private int health;
    private int attack;
    private int defense;
    private int healthPotions;

    public Player() {
        health = 100;
        attack = 10;
        defense = 5;
        healthPotions = 0;
    }

    public int getHealth() {
        return health;
    }

    public int getAttack() {
        return attack;
    }

    public int getDefense() {
        return defense;
    }

    public int getHealthPotions() {
        return healthPotions;
    }

    public void addHealthPotion() {
        healthPotions++;
    }

    public void upgradeWeapon() {
        attack += 5;
    }

    public void upgradeArmor() {
        defense += 3;
    }

    public void takeDamage(int damage) {
        int actualDamage = Math.max(1, damage - defense);
        health -= actualDamage;
    }

    public void useHealthPotion() {
        if (healthPotions > 0) {
            health = Math.min(100, health + 30);
            healthPotions--;
            System.out.println("Used health potion. Health: " + health);
        } else {
            System.out.println("No health potions left!");
        }
    }

    public void displayStats() {
        System.out.println("Player Stats:");
        System.out.println("Health: " + health);
        System.out.println("Attack: " + attack);
        System.out.println("Defense: " + defense);
        System.out.println("Health Potions: " + healthPotions);
    }
}
